home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 1.8 KB | 100 lines | [TEXT/ttxt] |
- --<<<
-
-
-
-
- class grid (TwoDPresenter)
- instance variables
-
- NofHorizLines:20
- NofVertLines:20
-
- linev :(new line x1:0 y1:0 x2:0 y2:100)
- lineh: (new line x1:0 y1:0 x2:100 y2:0)
-
- matrixv:(mutablecopy identityMatrix)
- matrixh:(mutablecopy identityMatrix)
- horizBrush:(new Brush \
- color:(new RGBColor \
- red:150 blue:150 green:150))
- vertBrush:(new Brush \
- color:(new RGBColor \
- red:150 blue:150 green:150))
-
- stroke:(new brush color:blackColor)
- fill:(new brush color:whitecolor)
- end
-
-
- method draw self {class Grid} surface clip ->
- (
- local globalTrans := self.globalTransform
-
- -- fill in the area
- local fillBrush := self.fill
- if (not fillBrush = undefined) do
- fill surface self.bbox clip globalTrans fillBrush
-
- local horizBrush := self.horizBrush
- local vertBrush := self.vertBrush
-
- local linev := self.linev
- linev.y2 := self.height
- local lineh := self.lineh
- lineh.x2 := self.width
-
- horizTrans := self.height / self.NofHorizLines
- vertTrans := self.width / self.NofVertLines
-
- -- local matrixv := mutableCopy globalTrans
- local matrixv := self.matrixv
- setTo matrixv globalTrans
-
- -- local matrixh := mutableCopy globalTrans
- local matrixh := self.matrixh
- setTo matrixh globalTrans
-
- for i in 1 to (self.NofVertLines - 1)
- do
- (translate matrixv vertTrans 0
- fill surface linev clip matrixv vertBrush
- )
- for i in 1 to (self.NofHorizLines - 1) do
- (
- translate matrixh 0 horizTrans
- fill surface lineh clip matrixh horizBrush
- )
-
- -- stroke the outline
- local strokeBrush := self.stroke
-
-
- if (not strokeBrush = undefined) do
- stroke surface self.bbox clip globalTrans strokeBrush
-
-
- )
-
- w := new window
- w.width := 500
- w.height := 400
-
- show w
-
-
- global grid1 := new grid boundary:(new rect x2:200 y2:100)
-
- append w grid1
-
- grid1.x := 50
- grid1.y := 50
-
- -->>>
-
- grid1.width := 200
- grid1.height := 200
- grid1.width := 100
- grid1.height := 100
-
-
-